def BubbleSort(r):
    n=len(r)
    if n<=1:
        return r
    for i in range (0,n):
        for j in range(0,n-i-1):
            if r[j]>r[j+1]:
                (r[j],r[j+1])=(r[j+1],r[j])
    return r

    
r=[1,5,3,2,4]
print(BubbleSort(r))